package ihistoryApp.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum BattleResponseTypeEnum {
    Unknown(0, "未知"),
    Match_Success(1, "匹配完成"),
    Next_Question(2, "拿到下一题"),
    Make_Answer(3, "作答结果"),
    Complete(4, "比赛结束")
    ;
    @JsonValue
    private final int value;
    private final String name;

    @JsonCreator
    public static BattleResponseTypeEnum of(int value) {
        for (BattleResponseTypeEnum type : BattleResponseTypeEnum.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        return Unknown;
    }
}
